<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
  <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
  <title>支付页-成功</title>

  <link rel="stylesheet" type="text/css" href="./css/webbase.css" />
  <link rel="stylesheet" type="text/css" href="./css/pages-paysuccess.css" />
  <style>
    .cart {
      max-width: 1200px;
      margin: 0 auto;
      padding: 20px;
    }
    .paysuccess {
      background-color: #fff;
      border-radius: 8px;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
      padding: 30px;
      margin-top: 20px;
      text-align: center;
    }
    .success h3 {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      color: #28a745;
      font-size: 24px;
      margin-bottom: 20px;
    }
    .paydetail {
      background-color: #f8f9fa;
      border-radius: 4px;
      padding: 20px;
      max-width: 500px;
      margin: 0 auto;
    }
    .paydetail p {
      margin: 10px 0;
      font-size: 16px;
      color: #495057;
    }
    .button {
      margin-top: 20px;
    }
    .sui-btn {
      padding: 12px 24px;
      border-radius: 4px;
      text-decoration: none;
      font-weight: bold;
      transition: background-color 0.3s;
    }
    .btn-danger {
      background-color: #dc3545;
      color: white;
    }
    .btn-danger:hover {
      background-color: #c82333;
    }
    .btn-xlarge:not(.btn-danger) {
      background-color: #6c757d;
      color: white;
    }
    .btn-xlarge:not(.btn-danger):hover {
      background-color: #5a6268;
    }
    @media (max-width: 768px) {
      .success h3 {
        flex-direction: column;
        text-align: center;
      }
      .paydetail {
        padding: 15px;
      }
      .sui-btn {
        display: block;
        margin: 10px auto;
        width: 80%;
      }
    }
  </style>
</head>

<body>
<div id="app">
<!--head-->
  <top></top>
<div class="cart py-container">
  <!--logoArea-->
  <div class="logoArea">
    <a href="/">
      <div class="logo">
        <img src="./img/logo.png" alt="1" />
      </div>
    </a>
    <span>支付结果 </span>
  </div>
  <!--主内容-->
  <div class="paysuccess">
    <div class="success">
      <h3><img src="img/right.png" width="48" height="48">　恭喜您，支付成功啦！</h3>
      <div class="paydetail">
        <p>支付方式：{{paymentTypes[order.paymentType - 1]}}</p>
        <p>支付金额：￥{{util.formatPrice(order.totalFee)}}元</p>
        <p>预计{{sendDate}}到达</p>
        <p class="button">
          <a href="/index.html" class="sui-btn btn-xlarge btn-danger">返回首页</a>&nbsp;&nbsp;&nbsp;&nbsp;
          <a href="/search.html" class="sui-btn btn-xlarge ">继续购物</a>
        </p>
      </div>
    </div>

  </div>
</div>
</div>
<script src="./js/vue.js"></script>
<script src="./js/axios.min.js"></script>
<script src="js/common.js"></script>
<script src="js/top.js"></script>
<script>
  let app = new Vue({
    el: "#app",
    data(){
      return {
        order: {}, // 订单信息
        paymentTypes: ["支付宝支付", "微信支付", "扣减余额"],
        util,
        user: null,
      }
    },
    created(){
      util.store.set("return-url", location.href);
      // 查询用户
      this.user = util.store.get("user-info");
      if(!this.user){
        location.href = "/login.html";
      }
      // 根据订单id查询订单
      axios.get("/orders/" + util.getUrlParam("orderId"))
        .then(resp => {
          // 查询到订单了
          this.order = resp;
        })
        .catch(err => console.log(err));
    },
    methods:{

    },
    computed:{
      sendDate(){
        if(!this.order.createTime){
          return "";
        }
        let d = new Date(this.order.createTime);
        return d.getFullYear() + "年" + (d.getMonth() + 1) + "月" + (d.getDate() + 3)  + "日"
      }
    }
  });
</script>
</body>

</html>